﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;

namespace WebService_Newstore.DAO
{
    public class UserConfDAO:BaseDAO
    {
        public int confID { get; set; }
        public int userID { get; set; }

        public UserConfDAO() { }

        public static ArrayList FindConfByUserID(int idUser)
        {
            ArrayList listConf = new ArrayList();
            using (newStoreContext = new newStoreEntities())
            {
                try
                {
                    var userconfQuery = from user_conf in newStoreContext.user_conf
                                        where user_conf.id_user == idUser
                                        select user_conf.id_conf;

                    if (userconfQuery.LongCount() == 0)
                    {
                        throw new Exception("Pas de conf pour ce user !!"); 
                    }
                    else
                    {

                        foreach (var conf in userconfQuery)
                        {
                            listConf.Add(conf);
                        }
                        return listConf;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.ReadLine();
                    listConf.Clear();
                    return listConf;
                }
            }
           
        }
    }
}